<?php 
	$PageName = 'menu';
	include_once(PUBLIC_BEHIND_DIRECTORY . $PageName . '.php');
?>
<script type="text/javascript">
$(function(){
	$(".linksSocial img").click(function(){
		link = $(this).data("url");
		if (link)
			window.open(link);
	});
	
	$("ul.subnav").parent().append("<span></span>");
	$("ul.topnav li").mouseenter(function(){
		$(this).find('a').addClass('selected');
		$(this).find('span').addClass('subhover');
		$(this).find("ul.subnav").slideDown('fast').show().css('z-index','1000');
		$(this).addClass("subhover");
	});

	$('ul.topnav li').mouseleave(function(){
		$(this).parent().find("ul.subnav").slideUp('fast');
		$(this).find('a').removeClass('selected');
		$(this).parent().find('span').removeClass('subhover');
	});
	
	$('[data-path]').on('click', function(){		
		prepareDynamicParameters($(this));
		
		var querystring = '';
		var parameters = $(this).data('parameters');
		if (parameters != undefined){
			$(parameters.split('&')).each(function(parameterKey, parameterValue){
				if (parameterValue == "") return false;
				var param = parameterValue.split('=');
				querystring += '/' + encodeURIComponent(param[1]);
			});
		}
		
		$(location).attr('href', '<?=MAIN_PATH;?>' + $(this).data('path') + querystring);
	});
	
	function prepareDynamicParameters ($elem){
		var inputId = $elem.data('parameters-input');
		if (inputId == undefined) return;
		
		$(inputId.split(',')).each(function(k, v){
			var $currentInput = $('#' + v);
			if ($currentInput == undefined) return false;
			var parameter = encodeURIComponent($currentInput.val()); 
			$elem.data('parameters', $currentInput.data('parameter-key') + '=' + parameter + '&');
		});
	};
});
</script>

<div id="mainMenu">
	<ul class="topnav">
		<li><a href="javascript: void(0);" data-path="home">Home</a></li>
		<li class="menuList">
			<a href="javascript: void(0);" class="menuTitle">ATP</a>
			<ul class="subnav">
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneo" data-parameters="id=<?=$MastersCup['masters_cup-m']->getId();?>&name=masters-cup">Masters Cup</a></li>
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneos" data-parameters="id=<?=$arrClasses['masters_1000'];?>&name=masters-1000">Masters 1000</a></li>
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneos" data-parameters="id=<?=$arrClasses['atp_500'];?>&name=ATP-500">ATP 500</a></li>
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneos" data-parameters="id=<?=$arrClasses['atp_250'];?>&name=ATP-250">ATP 250</a></li>
			</ul>
		</li>
		<li class="menuList">
			<a href="javascript: void(0);" class="menuTitle">Grand Slam</a>
			<ul class="subnav">
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneo" data-parameters="id=<?= $GrandSlams['abierto_de_australia-m']->getId() . "-" . $GrandSlams['abierto_de_australia-f']->getId();?>&name=australian-open">Abierto de Australia</a></li>
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneo" data-parameters="id=<?= $GrandSlams['roland_garros-m']->getId() . "-" . $GrandSlams['roland_garros-f']->getId();?>&name=roland-garros">Roland Garros</a></li>
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneo" data-parameters="id=<?= $GrandSlams['wimbledon-m']->getId() . "-" . $GrandSlams['wimbledon-f']->getId();?>&name=wimbledon">Wimbledon</a></li>
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneo" data-parameters="id=<?= $GrandSlams['us_open-m']->getId() . "-" . $GrandSlams['us_open-f']->getId();?>&name=us-open">US Open</a></li>
			</ul>
		</li>
		<li class="menuList">
			<a href="javascript: void(0);" class="menuTitle">Copa Davis</a>
			<ul class="subnav">
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneo" data-parameters="id=<?= $NationalTournaments["grupo_mundial-m"]->getId();?>&name=davis-grupo-mundial">Grupo Mundial</a></li>
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneo" data-parameters="id=<?= $NationalTournaments["repechaje-m"]->getId();?>&name=davis-repechaje">Repechaje</a></li>
			</ul>
		</li>
		<li class="menuList">
			<a href="javascript: void(0);" class="menuTitle">Copa Fed</a>
			<ul class="subnav">
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneo" data-parameters="id=<?= $NationalTournaments["grupo_mundial-f"]->getId();?>&name=fed-grupo-mundial">Grupo Mundial</a></li>
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneo" data-parameters="id=<?= $NationalTournaments["repechaje-f"]->getId();?>&name=fed-repechaje-i">Repechaje</a></li>
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneo" data-parameters="id=<?= $NationalTournaments["grupo_mundial_ii-f"]->getId();?>&name=fed-grupo-mundial-ii">Grupo Mundial II</a></li>
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneo" data-parameters="id=<?= $NationalTournaments["repechaje_ii-f"]->getId();?>&name=fed-repechaje-ii">Repechaje</a></li>
			</ul>
		</li>
		<li class="menuList">
			<a href="javascript: void(0);" class="menuTitle">WTA</a>
			<ul class="subnav">
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneos" data-parameters="id=<?=$arrClasses['premier'];?>&name=premier">Premier</a></li>
				<li><a href="javascript: void(0);" class="menuLink" data-path="torneos" data-parameters="id=<?=$arrClasses['international'];?>&name=international">International</a></li>
			</ul>
		</li>
		<li class="menuList"><a href="javascript: void(0);" class="menuLink" data-path="entrevistas">Entrevistas</a></li>
		<li class="menuList"><a href="javascript: void(0);" class="menuLink" data-path="links">Links</a></li>
<!--		<li class="menuList"><a href="javascript: void(0);" class="menuLink" data-link="who_are">Quienes Somos</a></li> -->
		<li class="menuList"><a href="javascript: void(0);" class="menuLink" data-path="contacto">Cont&aacute;ctenos</a></li>

		<li class="menuList linksSocial">
			<div>
				<img src="<?=PUBLIC_IMAGES_PATH;?>mini_facebook.gif" data-url="https://www.facebook.com/pages/A-Todo-Tenis/121057314585222" id="fbkLink" />
				<img src="<?=PUBLIC_IMAGES_PATH;?>mini_twitter.gif" data-url="https://twitter.com/#!/atodotenis/" id="twtLink" />
				<img src="<?=PUBLIC_IMAGES_PATH;?>mini_rss.png" data-path="rss" id="rssLink" />
				<img src="<?=PUBLIC_IMAGES_PATH;?>mini_youtube.png" data-url="http://www.youtube.com/user/atodotenis08?feature=results_main" id="ytbLink" />
			</div>
		</li>
	</ul>
</div>